﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class Serve
    {

        public bool insert1(Model.Serve mLKMT)
        {
            string sql = "insert into Serve (UserID,Name,Number,Iteams,StaName) values(@UserID, @Name,@Number,@Iteams,@StaName)";
            List<SqlParameter> sqlParams = new List<SqlParameter>();
            //sqlParams.Add(new SqlParameter("@SerID", mLKMT.SerID));
            sqlParams.Add(new SqlParameter("@UserID", mLKMT.UserID));
            sqlParams.Add(new SqlParameter("@Name", mLKMT.Name));
            sqlParams.Add(new SqlParameter("@Number", mLKMT.Number));
            sqlParams.Add(new SqlParameter("@Iteams", mLKMT.Iteams));
            sqlParams.Add(new SqlParameter("@StaName", mLKMT.StaName));
            return DBUtitlity.DbHelperSQL.ExecuteSql(sql, sqlParams);
        }
        public bool update(Model.Serve mLKMT, string oldSerID)
        {
            string sql = "update Serve set  UserID=@UserID,Name= @Name,Number=@Number,Iteams=@Iteams,StaName=@StaName where SerID=@oldSerID";
            List<SqlParameter> sqlParams = new List<SqlParameter>();
            //sqlParams.Add(new SqlParameter("@SerID", mLKMT.SerID));
            sqlParams.Add(new SqlParameter("@UserID", mLKMT.UserID));
            sqlParams.Add(new SqlParameter("@Name", mLKMT.Name));
            sqlParams.Add(new SqlParameter("@Number", mLKMT.Number));
            sqlParams.Add(new SqlParameter("@Iteams", mLKMT.Iteams));
            sqlParams.Add(new SqlParameter("@StaName", mLKMT.StaName));
            sqlParams.Add(new SqlParameter("@oldSerID", oldSerID));
            return DBUtitlity.DbHelperSQL.ExecuteSql(sql, sqlParams);
        }
        public bool delete(string SerID)
        {
            string sql = "delete from Serve where SerID=@SerID";
            List<SqlParameter> sqlParams = new List<SqlParameter>();
            sqlParams.Add(new SqlParameter("@SerID", SerID));
            return DBUtitlity.DbHelperSQL.ExecuteSql(sql, sqlParams);
        }
        public DataTable select(string strWhere)
        {
            //string sql = "select Serve.SerID as SerID,UserID,Name,Number,Iteams,StaNamer from Users left join Serve on  Users. UserID=Serve.UserID ";
            string sql = "select * from Serve";
            if (strWhere != "")
            {
                sql += " where " + strWhere;
            }
            return DBUtitlity.DbHelperSQL.Query(sql);
        }
    }
}
